/**
 * There are code generation
 */
package com.neusoft.lohas.modules.ivm.dao.purchase;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.neusoft.lohas.common.persistence.BaseDao;
import com.neusoft.lohas.common.persistence.Parameter;
import com.neusoft.lohas.common.utils.StringUtils;
import com.neusoft.lohas.modules.ivm.entity.purchase.PurchaseDetail;

/**
 * 采购单详情DAO接口
 * @author Jackie.Liu
 * @version 2014-12-29
 */
@Repository
public class PurchaseDetailDao extends BaseDao<PurchaseDetail> {
	
	public List<PurchaseDetail> getDetails(String purchaseInfoId, String supplierId){
		String sql = "select a.* from ivm_purchase_detail a inner join ivm_product b on a.product_id = b.id left join ivm_purchase_order c on a.purchase_order_id=c.id where a.info_id='"+purchaseInfoId+"' and a.del_flag='0'";
		if (StringUtils.isNotBlank(supplierId)) {
			sql += " and b.default_supplier_id='"+supplierId+"'";
		}
		sql += " order by c.member_id,b.default_supplier_id";
		return findBySql(sql, new Parameter(), PurchaseDetail.class);
	}
	
}
